<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/page/share/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="pragma" content="no-cache">
<META http-equiv="Cache-Control" content="no-cache, must-revalidate">
<META http-equiv="expires" content="Wed, 26 Feb 2006 08:21:57 GMT">
<META http-equiv="Content-TYPE" content="text/html; charset=UTF-8">
<link href="/shop/css/global/address.css" rel="stylesheet" type="text/css">
<link href="/shop/css/global/bottom.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="/shop/css/global/top.css" media="all" type="text/css"/>
<link rel="stylesheet" href="/shop/css/shopping/delivery.css" media="all" type="text/css"/>
<TITLE>52橙子网：结算中心：填写收货地址</TITLE>
<SCRIPT LANGUAGE="JavaScript" src="/shop/js/Country.js" type="text/javascript"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="/shop/js/provinceArea.js" type="text/javascript"></SCRIPT>
<SCRIPT language=JavaScript src="/shop/js/FoshanRen.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
/*
 * 功能：取单选框的值
 */
function getradiovalue(objradio){
		var result = "";
		try{
			if(typeof(objradio.value)=="undefined"){
				for(var i=0;i<objradio.length;i++){
					if(objradio[i].checked){
						return objradio[i].value;
					}
				}
			}else{
				if(objradio.checked) result = objradio.value;
			}
		}catch(e){result = "";}
		return result;
}

function buyerinfoSelect(issame){
	if("true"==issame){
		document.getElementById('buyerinfoInput').style.display="none";
	}else{
		document.getElementById('buyerinfoInput').style.display="";
	}
}
//email验证
function isValidEmail(inEmail){
	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return filter.test(inEmail);
}
	/**
	* FormField类,描述表单字段,第一个参数为字段的name属性值,第二个参数为字段的中文名
	*/
	function FormField(fieldName, fieldLabel){
		this.fieldName = fieldName;
		this.fieldLabel = fieldLabel;
	}
	//验证表单数据
	function validateFormData(){
		var form = document.forms[0];
		var fields = new Array(new FormField("recipients","收货人姓名"), new FormField("address","收货人地址"),
						new FormField("email","电子邮件"), new FormField("postalcode","邮政编码"));
		for(var i=0;i<fields.length;i++){
			var field = eval("form."+ fields[i].fieldName);
			if(field.value.trim()==""){
				alert(fields[i].fieldLabel+ " 不能为空");
				return false;
			}
		}
		if(getradiovalue(form.gender)==""){
			alert("请选择收货人的性别");
			return false;
		}		
		if(!isValidEmail(form.email.value)){
			alert("收货人的email格式不正确");
			return false;
		}
		if(!/^\d{6}$/.test(form.postalcode.value.trim())){
			alert("收货人的邮政编码必须是6位数字");
			return false;
		}
		if(form.mobile.value.trim()!=""){
			if(!/^1[35]\d{9}$/.test(form.mobile.value.trim())){
				alert("收货人的手机号格式不正确");
				return false;
			}
		}
		form.tel.value = "";
		if(form.maintel.value.trim()!=""){
			if(/^\d{7,8}$/.test(form.maintel.value.trim())){
				form.tel.value = form.forepart.value+"-"+ form.maintel.value;
				if(form.extension.value.trim()!="") form.tel.value += "-"+ form.extension.value;
			}else{
				alert("收货人的电话号码至少7位");
				return false;
			}
		}
	
		if(form.tel.value=="" && form.mobile.value.trim()==""){
			alert("收货人的手机和电话至少有一项必填");
			return false;
		}
		
		if(getradiovalue(form.buyerIsrecipients)=="false"){
			var buyerfields = new Array(new FormField("buyer","购买者的姓名"), new FormField("buyer_address","购买者的地址"),
						new FormField("buyer_postalcode","购买者的邮政编码"));
			for(var i=0;i<buyerfields.length;i++){
				var buyerfield = eval("form."+ buyerfields[i].fieldName);
				if(buyerfield.value.trim()==""){
					alert(buyerfields[i].fieldLabel+ " 不能为空");
					return false;
				}
			}
			if(getradiovalue(form.buyer_gender)==""){
				alert("请选择购买者的性别");
				return false;
			}			
			form.buyer_tel.value = "";
			if(/^\d{7,8}$/.test(form.buyer_maintel.value.trim())){
				form.buyer_tel.value = form.buyer_forepart.value+"-"+ form.buyer_maintel.value;
				if(form.buyer_extension.value.trim()!="") form.buyer_tel.value += "-"+ form.buyer_extension.value;
			}
			if(form.buyer_tel.value=="" && form.buyer_mobile.value.trim()==""){
				alert("购买者的手机和电话至少有一项必填");
				return false;
			}
		}
		return true;
	}
function sendForm(){
	var form = document.forms[0];
	if(validateFormData()) form.submit();
}

	function pageinit(){
		initPhone();
		showBuyInfo();
	}
	
	function showBuyInfo(){
		var form = document.forms[0];
		if(getradiovalue(form.buyerIsrecipients)=="false") 
			document.getElementById('buyerinfoInput').style.display="";
	}
	
	function initPhone(){
		var form = document.forms[0];
		var phone = form.tel.value;
		if(phone!=""){
			var tels = phone.split("-");
			if(tels.length>=2){
				form.forepart.value = tels[0];
				form.maintel.value = tels[1];
				if(tels.length==3) form.extension.value = tels[2];
			}
		}
		var buyerphone = form.buyer_tel.value;
		if(buyerphone!=""){
			var tels = buyerphone.split("-");
			if(tels.length>=2){
				form.buyer_forepart.value = tels[0];
				form.buyer_maintel.value = tels[1];
				if(tels.length==3) form.buyer_extension.value = tels[2];
			}
		}
	}
//-->
</SCRIPT>

<META content="MSHTML 6.00.2900.2769" name="GENERATOR">
</HEAD>
<BODY onload="pageinit()">
<div class="container">
<jsp:include page="/WEB-INF/page/share/Head.jsp"></jsp:include>
<html:form action="/customer/shopping/manage" method="post">
<input type="hidden" name="directUrl" value="${param.directUrl }">
<INPUT TYPE="hidden" NAME="method" value="saveDeliverInfo">

      <div class="type">
        	<img src="/shop/image/shopping/delivery_type_icon.png"/>
      </div>
      <div class="box">
         <div class="box_header">
            <div><font>请输入配送地址:</font></div>
         </div>
         <div class="box_body">
           	<div class="box_body_content">
               <div class="left">收货人姓名:</div>
               <div class="right">
                  <html:text property="recipients" maxlength="8" size="30px"/>
                  <FONT color="#ff0000">*</FONT>&nbsp;
                  <html:radio property="gender" value="MAN"/>先生 
                  <html:radio property="gender" value="WOMEN"/>女士
               </div>
            </div>
            <div class="box_body_content">
              	<div class="left">收货人地址:</div>
                <div class="right">
                   	<html:text property="address" maxlength="100" size="60px"/><FONT color="#ff0000">*</FONT>
                </div>
            </div>
            <div class="box_body_content">
             	<div class="left">电子邮箱:</div>
                <div class="right">
                   	<html:text property="email" maxlength="45" size="30px"/><FONT color="#ff0000">*</FONT>
                </div>
            </div>
            <div class="box_body_content">
              	<div class="left">邮政编码:</div>
                <div class="right">
                  	<html:text property="postalcode" maxlength="6" size="20px"/><FONT color="#ff0000">*</FONT> 
                  	<font color="#484848">请正确填写邮政编码，以免延误您的订单送达时间。不知道邮编？
                  	<a href="http://www.cpdc.com.cn/webmodules/postcode/CPDC_03G01.aspx" target="_blank">请进这里查询</a></font>
                    </div>
                </div><html:hidden property="tel" />
                <div class="box_body_content">
                	<div class="left">电话:</div>
                    <div class="right">
                    	<input value="010" size="4px" name="forepart" maxlength="4" onkeypress="javascript:InputIntNumberCheck()">&nbsp;&nbsp;
                        <input name="maintel" size="8px" maxlength="8" onkeypress="javascript:InputIntNumberCheck()">&nbsp;&nbsp;
                        <input name="extension" size="4px" maxlength="4" onkeypress="javascript:InputIntNumberCheck()">
                    </div>
                    <div><span class="STYLE1">区号</span>&nbsp;&nbsp; <span class="STYLE1">电话号码</span>&nbsp;&nbsp;
               				<span class="STYLE1">分机</span></div>
                </div>
                <div class="box_body_content">
                	<div class="left">手机:</div>
                    <div class="right">
                    	<html:text property="mobile" maxlength="15" size="20px"/><font color="#484848">（手机和电话至少有一项必填）</font>
                    </div>
                </div>
                <div class="box_body_content">
                	<div class="left">购买人与收货人是否相同:</div>
                    <div class="right">
                    	<html:radio property="buyerIsrecipients" value="true" onclick="javascript:buyerinfoSelect(this.value)"/> <b>相同</b>
		  				<html:radio property="buyerIsrecipients" value="false" onclick="javascript:buyerinfoSelect(this.value)"/> <b>不相同</b>
                    </div>
                </div>
                <!--不相同时显示-->
                <div id="buyerinfoInput" class="different" style="DISPLAY: none">
                	<div class="box_body_line"></div>
                    <div class="box_body_content">
                        <div class="left">购买者姓名:</div>
                        <div class="right">
                            <html:text property="buyer" maxlength="8" size="30px" />
              				&nbsp;<html:radio property="buyer_gender" value="MAN" />先生 <html:radio property="buyer_gender" value="WOMEN"/>女士
                        </div>
                    </div>
                    <div class="box_body_content">
                        <div class="left">详细地址:</div>
                        <div class="right">
                            <html:text property="buyer_address" maxlength="100" size="60px" />
                            <font style="color:#ff0000;">*</font>
                        </div>
                    </div>
                    <div class="box_body_content">
                        <div class="left">邮政编码:</div>
                        <div class="right">
                            <html:text property="buyer_postalcode" maxlength="6" size="20px"/>
                            <font style="color:#ff0000;">*</font>
                            &nbsp;&nbsp;<font color="#484848">请正确填写邮政编码，以免延误您的订单送达时间。</font> 
                        </div>
                    </div>
                    <div class="box_body_content">
                        <div class="left">电话:</div>
                        <div class="right">
                            <input value="010" size="4px" name="buyer_forepart" maxlength="4" onkeypress="javascript:InputIntNumberCheck()">
							&nbsp;&nbsp;<input name="buyer_maintel" size="8px" maxlength="8" onkeypress="javascript:InputIntNumberCheck()">
                            &nbsp;&nbsp;<input name="buyer_extension" size="4px" maxlength="4" onkeypress="javascript:InputIntNumberCheck()">
                            <html:hidden property="buyer_tel" />
                        </div>
                        <div><font color="#484848">区号</font>&nbsp;&nbsp;
                        <font color="#484848">电话</font>&nbsp;&nbsp;
                        <font color="#484848">分机</font></div>
                    </div>
                    <div class="box_body_content">
                        <div class="left">手机:</div>
                        <div class="right">
                            <html:text property="buyer_mobile" maxlength="15" size="20px"/> 
                        </div>
                    </div>
                </div>
                <div class="box_next"><img src="/shop/image/shopping/next_btn.png" onClick="javascript:sendForm()" vspace=5 border=0 style="CURSOR: hand;"/></div>                
            </div>   
        
        </div>
</html:form>

<jsp:include page="/WEB-INF/page/share/Foot.jsp"/>
</div>
</BODY></HTML>